Object: rule_set

Description

The heart of the knowledgebase is the rules. Rules can either directly determine the value of a top-level goal (see knowledgebase), or they can determine the values of other facts. All the rules for a specific goal are in the same rule object. For example, all the rules that determine a value for problem are contained in the rule object named 'problem'.

Here is a simple rule for 'problem':

conditions
value
errorMessage = "Code too long to load"
srcbufTooSmall

It says if the fact 'errorMessage' has the value specified then the problem is 'srcbufTooSmall'. Now there is nothing particularly difficult or remarkable about this rule, nor is there about most of the rules in KnowledgeWright . What is notable is that the rules are easy to read and can appear in the object in any order. The KnowledgeWright 'reasoning engine' (that's a fancy way to say search and pattern matching engine) scans the rules looking for ones that 'succeed.' A rule is said to succeed when all of the facts on the 'if' side match correctly.

Before we examine the inference engine, lets look at some more rules. This one is for the rule 'language':

conditions
value
languageTool = "Visual C++" or
languageTool = "Borland C++" or
languageTool = "Watcom C++"
"C/C++"

This rule distills the fact 'language' from the user-provided fact 'languageTool'. This allows us to simplify rules such as the following for 'problem':

conditions
value
language = "C/C++" and
apiFunction = "lsInit" and
((errorMessage = "GPF (General Protection Fault)" and 
environmentNameVer = "Windows 3.x") or
environmentNameVer = "DOS")
cLargeModelRequired

Note here that more of the power of the rule language becomes evident. We can use 'and', 'or' and parenthesis to check facts.

Default Values

You can also use a simple formula in a rule to specify a default value. For example, here are some rules for 'gifts':

conditions
value
behavior = "good"
"lots"
behavior = "bad"
"little"
default
"some"

If behavior is neither 'good' nor 'bad' then the value of gifts is 'some'.

Comparators, Operators, Functions and Constants

You can use a variety of comparators, operators, functions and constants in the conditions column. See Expressions for details.

Rule Order

The order in which the rules appear in the table is significant. The KnowledgeWright reasoning engine examines the table in order starting with the first row, and examines the rule conditions from left to right.

In general, this means you want to put the more general conditions at the top left, and the more specific conditions at the bottom right. The reason to do this is because the reasoning engine in KnowledgeWright will ask the user a question as soon as it encounters a fact it doesn't have a value for. If the more general questions are asked first, then KnowledgeWright will more quickly filter out the rules that do not apply.

Rule Syntax

Rules must follow these syntatic guidelines:

Rule_Set Properties

Rules have the following properties:

Property Name Description Default Value Required
id The name of this object. See Object Names for details. <none> yes
path The folder this object is located in. See Folders for details. / yes
description A text description (comment)--not used during reasoning. <none> no
type Whether or not these rules result in a fact (or goal) having a single value or multiple values.   yes
rules A table of conditions and their associated values. That is, when the conditions in the left column are met, the value of the rule_set object in the value in the right column.   yes


Copyright ©1996-2002 Amzi! inc. All Rights Reserved. Amzi!, KnowledgeWright and WebLS are registered trademarks and Subscription Plus and Logic Server are trademarks of Amzi! inc.